/**
* 串口增加测试模块
* 利用软串口增加串口
*/
#include <SoftwareSerial.h>

// 将2，3端口分别定义为 RX, TX串口
SoftwareSerial mySerial(2, 3);

String comdata = "";
void setup()
{
    Serial.begin(9600);
    Serial.println("Serial monitor starts successfully!");

    mySerial.begin(9600);
}

void loop()
{
    while (Serial.available() > 0)  
    {
        comdata += char(Serial.read());
        delay(2);
    }
    if (comdata.length() > 0)
    {
        Serial.println(comdata);
        Serial.write("successfully write data");
        mySerial.println("haha~~");
        mySerial.write("haha~~");        
        comdata = "";
    }
}
